package main

import (
	"net/http"
	"io/ioutil"
	"time"
	"fmt"

)

//client作为全局变量，发起多次call()调用时，因共享连接池，所以每次请求不会产生新的连接，而是复用第一次创建的连接
var client = &http.Client{
        Transport: &http.Transport{},
}

func Call(){
	resp, err := client.Get("http://127.0.0.1:9201/foo")
	if err != nil {
		// handle error
		fmt.Println("1111", err)
		return
	}
	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return
	}
	fmt.Println(string(body))
}

func main(){
    for {
		Call()
		time.Sleep(1 * time.Second)
    }
}
